import java.io.IOException;
import java.security.Key;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import sun.awt.SunHints.Value;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/5/11 10:11
 * @description:
 */
public class UserDaomap implements UserDao {
HashMap<String,User > map=new HashMap<String,User>();
  @Override
  public void register(User user) throws IOException {
    map.put(user.getName(),user);
  }

  @Override
  public boolean login(String name, String password) {
    Iterator iterator=map.keySet().iterator();
    String key= (String) iterator.next();
    User value=map.get(key);
    if(name.equals(key)&&password.equals(value.getPassword())){
      return true;
    }
    return false;
  }

  @Override
  public void quiteAll() {
Iterator iterator=map.entrySet().iterator();
while (iterator.hasNext()){
  Map.Entry<String,User> entry=(Map.Entry<String,User>) iterator.next();
    User value=entry.getValue();
    System.out.println(value);
  }
  }
}
